package GUI;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JButton;

import Controller.ParkingLotManagerController;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.awt.Font;

/**
 * this is the GUI for parking lot manager. the parking lot manager can only request for changing rates or create reports.
 * @author all of us.
 *
 */
public class ParkingLotManagerWin extends JPanel {
	JPanel cur=this;
	JFrame frame;
	JPanel lastPanel;
	public void setLastPanel (JPanel panel)
	{
		this.lastPanel=panel;
	}
	public JPanel getLastPanel()
	{
		return (JPanel)lastPanel;
	}
	public void setFrame (JFrame frame)
	{
		this.frame=frame;
	}

	/**
	 * is the constructor. it has only two buttons for creating reports or new request for changing rates.
	 */
	public ParkingLotManagerWin() {
		setBounds(100, 100, 927, 413);

		setBorder(new EmptyBorder(5, 5, 5, 5));
		setLayout(null);
		
		JLabel lblHello = new JLabel("Parking Lot Manager");
		lblHello.setBounds(150, 11, 134, 14);
		add(lblHello);
		
		JButton btnReportCreation = new JButton("Report Creation");
		btnReportCreation.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ReportCreation rc=new ReportCreation();
				rc.setFrame(frame);
				rc.setLastPanel(cur);
				rc.setVisible(true);
			}
		});
		btnReportCreation.setBounds(459, 168, 140, 23);
		add(btnReportCreation);
		
		JButton btnLogOut = new JButton("Log out");
		btnLogOut.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frame.setContentPane((JPanel)lastPanel);
			}
		});
		btnLogOut.setBounds(486, 307, 89, 23);
		add(btnLogOut);
		
		JButton btnCreateRequestFor = new JButton("Create Request for Changing Rates");
		btnCreateRequestFor.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				RequestForChangingRatesBoundary openrequest=new RequestForChangingRatesBoundary();
				openrequest.setFrame(frame);
				openrequest.setLastPanel(cur);
				openrequest.setVisible(true);
			}
		});
		btnCreateRequestFor.setBounds(412, 213, 236, 23);
		add(btnCreateRequestFor);
		
		JLabel lblHellowParkingLot = new JLabel("Hellow! Parking lot manager");
		lblHellowParkingLot.setFont(new Font("Tahoma", Font.PLAIN, 20));
		lblHellowParkingLot.setBounds(394, 84, 317, 50);
		add(lblHellowParkingLot);
	}
}
